package pathfinding.grid.astar;

import pathfinding.grid.GridLocation;

public class GridHeuristicOptimal implements GridHeuristic{

	private double minValue = 1;
	
	@Override
	public double getDistance(int x, int y, GridLocation location) {
		double result = 0;
		int dx = Math.abs(x-location.getCellX());
		int dy = Math.abs(y-location.getCellY());
		int min = Math.min(dx, dy);
		int dif = Math.abs(dx - dy);
		result += min*1.42;
		result += dif;
		result *= minValue;
		return result;
	}
	
	public void setMinValue(double value){
		minValue = value;
	}
	
	

}
